// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'

import axios from 'axios'
 import $ from 'jquery'
import iView from 'iview'
import VueAwesomeSwiper from 'vue-awesome-swiper' /* 使用轮播插件 */
import 'iview/dist/styles/iview.css'
import 'swiper/dist/css/swiper.css'
import Vant from 'vant'
import 'vant/lib/index.css'
import Loading from './pages/Loding'
import Mint from 'mint-ui'
import router from './router'
Vue.use(Mint)

Vue.use(Loading)

Vue.use(Vant)
Vue.config.productionTip = false
Vue.prototype.$http = axios
Vue.use(iView)
Vue.use(VueAwesomeSwiper) /* 使用轮播插件 */


// 判断要登录
router.beforeEach((to, from, next) => {
  if (to.matched.some(record => record.meta.requireAuth)){  // 判断该路由是否需要登录权限
    if (localStorage.token) {
      next();
    }
    else {
      next({
        path: '/login',
        query: {redirect: to.fullPath}
      })
    }
  }
  else {
    next();
  }
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
